package com.tamecode.chapter05.part11.sub2;

import com.tamecode.chapter05.part11.sub1.LogDao;
import com.tamecode.chapter05.part11.sub1.LogonService;
import com.tamecode.chapter05.part11.sub1.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 *
 * @Author: Liqc
 * @Date: 2022/12/23 13:20
 */
// ①通过 @ImportResource 引入 XML 配置文件
@Configuration
@ImportResource("classpath:bean/chap5-11/beans-02-bean.xml")
public class LogonAppConfig {

    // ②自动注入 XML 文件中定义的 Bean
    @Bean
    @Autowired
    public LogonService logonConfig(UserDao userDao, LogDao logDao) {
        LogonService logonService = new LogonService();
        logonService.setUserDao(userDao);
        logonService.setLogDao(logDao);
        return logonService;
    }


}
